import { LOGIN, LOGOUT } from '../constants'

const INITIAL_STATE = {
  isLogin: false,
  userInfo: {}
}

export default function userState (state = INITIAL_STATE, action) {
  switch (action.type) {
    case LOGOUT:
      return {
        ...state,
        isLogin: false,
        accountInfo: {}
      }
      break
    case LOGIN:
      return {
        ...state,
        isLogin: true,
        accountInfo: action.accountInfo || {}
      }
      break
    default:
      return state
      break
  }
}
